<%= render :partial => 'left_bar', :locals => { :on => 2 } %>
<script type="text/javascript">
var cats = <%= @cats%>;
var dftCat1 = <%= @params[:cat1_id].blank? ? 0 : @params[:cat1_id]%>;
var dftCat2 = <%= @params[:cat2_id].blank? ? 0 : @params[:cat2_id]%>;
var dftCat3 = <%= @params[:cat3_id].blank? ? 0 : @params[:cat3_id]%>;
</script>
<%=javascript_include_tag 'items/cat.list.admin' %>
<div id="main">
  <%form_tag admin_items_path,:method => :get do%>
    <div class="box">
      <table id="search" class="table border">
        <tr>
				<td valign="top" nowrap="nowrap" class="ws20" id="cat1_list"><strong>一级</strong>：<%=hidden_field_tag :cat1_id%></td>
			</tr>
			<tr class="tr2">
				<td class="ws20" id="cat2_list"><strong>二级</strong>：<%=hidden_field_tag :cat2_id%></td>
			</tr>
			<tr>
				<td class="ws20" id="cat3_list"><strong>三级</strong>：<%=hidden_field_tag :cat3_id%></td>
			</tr>
        <tr class="tr2">
          <td colspan="2"><label>编号：
              <input name="item_id" type="text" value="<%=@params[:item_id]%>" />
            </label>
            &nbsp;　&nbsp;
            <label>名称：
              <input name="item_title" type="text" value="<%=@params[:item_title]%>" />
            &nbsp;　&nbsp;
            <input type="hidden" name="sort" value="<%=@params[:sort]%>" id="sort"/>
            <input class="submit btt90" type="submit" value="查询" /></td>
        </tr>
      </table>
    </div>
  <% end %>
  <div class="clearfix mb10"><a class="btt btt90 bttb" href="#">上架</a> <a class="btt bttg btt90" href="#">下架</a> <a class="btt btt90 bttr" href="#">删除</a></div>
  <div class="box">
      <table id="ret_table" class="table border">
        <tr>
          <!--<th width="1"> <label>
              <input type="checkbox" name="checkbox" id="checkbox" />
            </label>
          </th>-->
          <th width="1">&nbsp;</th>
          <th>id</th>
          <th>分类</th>
          <th>名称</th>
          <th><a href="#" rel="<%= @params[:sort] == 'by_price_asc' ? 'by_price_desc' : 'by_price_asc' %>">价格<%= @params[:sort] == 'by_price_asc' ? '↓' : '↑'%></a></th>
          <th><a href="#" rel="<%= @params[:sort] == 'by_commission_asc' ? 'by_commission_desc' : 'by_commission_asc' %>">佣金<%= @params[:sort] == 'by_commission_asc' ? '↓' : '↑'%></a></th>
          <th><a href="#" rel="<%= @params[:sort] == 'by_commission_num_asc' ? 'by_commission_num_desc' : 'by_commission_num_asc' %>">推广量<%= @params[:sort] == 'by_commission_num_asc' ? '↓' : '↑'%></a></th>
          <th><a href="#" rel="<%= @params[:sort] == 'by_commission_volume_asc' ? 'by_commission_volume_desc' : 'by_commission_volume_asc' %>">累计量<%= @params[:sort] == 'by_commission_volume_asc' ? '↓' : '↑'%></a></th>
          <th>点击量</th>
          <th>转化量</th>
          <th width="1">促</th>
          <th width="1">免</th>
          <th><a href="#" rel="<%= @params[:sort] == 'by_created_at_asc' ? 'by_created_at_desc' : 'by_created_at_asc' %>">创建<%= @params[:sort] == 'by_created_at_asc' ? '↓' : '↑'%></a></th>
        </tr>
        <%@items.each do |item|%>
        <tr class="<%= cycle('', 'tr2') %>">
          <!--<td><input type="checkbox" name="checkbox" id="checkbox" /></td>-->
          <td></td>
          <td><%=item.id%></td>
          <td><%=show_cats(item)%></td>
          <td><a href="<%=item.detail_url%>" target="_blank"><%=item.title%></td>
          <td><%=item.price%></td>
          <td><%=item.taobaoke_item.commission%></td>
          <td><%=item.taobaoke_item.commission_num%></td>
          <td><%=item.taobaoke_item.commission_volume%></td>
          <td><%=item.item_statistic.nil? ? 0 : item.item_statistic.total_views %></td>
          <td><%=item.item_statistic.nil? ? 0 : item.item_statistic.total_ad_click %></td>
          <td><%=item.is_promotion == 0 ? 'N' : 'Y'%></td>
          <td><%=item.is_free_fee == 0 ? 'N' : 'Y'%></td>
          <td><%=item.created_at.to_date%></td>
        </tr>
        <% end %>
      </table>
  </div>
  <div class="page">
		<div class="fr"><%= will_paginate @items %>
		</div>
	</div>
  </div>
  
